import home from "../pages/home"
import about from "../pages/about"
import news from "../pages/news"
import message from "../pages/message"
import user from "../pages/user"
import userDetail from "../pages/userDetail"
export default [
    {
        path:"/home",
        component:home,
        children:[
            {path:"news",component:news},
            {path:"message",component:message},
            {path:"",redirect:"news"}
        ]
    },
    {path:"/about",component:about},
    {
        path:"/user",
        component:user,
        children: [
            //props:true  : vue-router会自动 将id(params数据)作为props传递给userDetail
            //props:{}    : vue-router会自动 将当前对象作为props传递给userDetail
            //props:函数(函数的参数是路由对象!)   : vue-router会自动 将函数返回的对象传递给userDetail
            // {path: ":id",component: userDetail,props:true}
            // {path: ":id",component: userDetail,props:{id:0,xxx:"xxx"}}
            {
                path: ":id",
                component: userDetail,
                props:route=>({
                    id:+route.params.id,
                    wife:route.query.wife
                })
            }
        ]
    },
    {path:"/",redirect:"/about"},
]